/* LLM智能对话助手样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 50%, #90caf9 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 删除头部样式 */

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #95a5a6;
    transition: background-color 0.3s ease;
}

.status-dot.connected {
    background: #27ae60;
    animation: pulse 2s infinite;
}

.status-dot.error {
    background: #e74c3c;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 主内容区域 */
.main-content {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.chat-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar {
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    padding: 20px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 消息容器 */
.messages-container {
    flex: 1;
    height: 0;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    margin-right: 0;
    margin-left: 12px;
}

.assistant-message .message-avatar {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.message-content {
    flex: 1;
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    padding: 15px 18px;
    border-radius: 20px;
    max-width: 70%;
    max-height: 300px;
    overflow-y: auto;
    word-wrap: break-word;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.user-message .message-content {
    background: #3498db;
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

/* 删除欢迎消息样式 */

/* 输入区域 */
.input-container {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    backdrop-filter: blur(10px);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: white;
    border-radius: 30px;
    padding: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    box-shadow: 0 12px 35px rgba(79, 172, 254, 0.2);
    border-color: #3498db;
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    font-family: inherit;
}

.send-button {
    width: 44px;
    height: 44px;
    border: none;
    background: #3498db;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.send-button:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.3);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-icon {
    font-size: 18px;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: #7f8c8d;
}

.status-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 侧边栏样式 */
.sidebar-section {
    margin-bottom: 25px;
}

.sidebar-section h3 {
    color: #2c3e50;
    font-size: 1.1em;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ecf0f1;
}

.demo-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 子菜单样式 */
.submenu-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 2px dashed #3498db;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.submenu-toggle:hover {
    background: #d5dbdb;
    border-color: #3498db;
}

.submenu-toggle::after {
    content: '▼';
    font-size: 12px;
    transition: transform 0.3s ease;
}

.submenu-toggle.active::after {
    transform: rotate(180deg);
}

.submenu-content {
    display: none;
    flex-direction: column;
    gap: 4px;
    margin-left: 20px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.submenu-content.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.submenu-item {
    padding: 10px 14px;
    border: 1px dashed #bdc3c7;
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.submenu-item:hover {
    background: #ecf0f1;
    border-color: #95a5a6;
    transform: translateX(4px);
}

.demo-btn {
    padding: 12px 16px;
    border: 2px dashed #bdc3c7;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.demo-btn:hover {
    background: #d5dbdb;
    border-color: #95a5a6;
}

.system-info {
    font-size: 14px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #ecf0f1;
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    color: #7f8c8d;
    font-weight: 500;
}

.info-value {
    color: #2c3e50;
    font-weight: 600;
}

.tools-list {
    font-size: 14px;
}

/* 工具分类样式 */
.tool-category, .mcp-server-category {
    margin-bottom: 16px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.category-header.clickable:hover {
    background: linear-gradient(135deg, #e9ecef, #f8f9fa);
}

/* MCP服务器头部特殊样式 */
.category-header.mcp-header {
    background: linear-gradient(135deg, #fff3cd, #fffbf0);
    border-bottom: 1px solid #ffeaa7;
}

.category-header.mcp-header:hover {
    background: linear-gradient(135deg, #ffeaa7, #fff3cd);
}

.category-icon {
    font-size: 18px;
    margin-right: 8px;
}

.category-name {
    flex: 1;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.category-count {
    font-size: 12px;
    color: #6c757d;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    margin-right: 8px;
}

/* MCP标签 */
.mcp-badge {
    background: #fd7e14;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    margin-right: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-toggle {
    font-size: 14px;
    color: #6c757d;
    font-weight: bold;
    transition: transform 0.2s ease;
    margin-left: 4px;
}

/* 工具列表折叠效果 */
.category-tools {
    padding: 8px;
    background: #fafbfc;
    transition: all 0.3s ease;
    overflow: hidden;
}

.category-tools.expanded {
    max-height: none;
    opacity: 1;
}

.category-tools.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.tool-item {
    padding: 10px 12px;
    background: #ffffff;
    border-radius: 6px;
    margin-bottom: 6px;
    border-left: 4px solid #3498db;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tool-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.15);
}

.tool-item:last-child {
    margin-bottom: 0;
}

.tool-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
}

/* MCP工具特殊样式 */
.tool-item.mcp-tool {
    border-left-color: #fd7e14;
    background: linear-gradient(135deg, #ffffff, #fffbf7);
}

.tool-item.mcp-tool:hover {
    box-shadow: 0 2px 6px rgba(253, 126, 20, 0.15);
}

.tool-item.mcp-tool .tool-name {
    color: #d63384;
}

.tool-desc {
    color: #7f8c8d;
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.4;
}

/* Function Calling工具分类颜色区分 */
.tool-category:nth-child(1) .tool-item:not(.mcp-tool) {
    border-left-color: #3498db; /* 系统管理 - 蓝色 */
}

.tool-category:nth-child(2) .tool-item:not(.mcp-tool) {
    border-left-color: #8e44ad; /* 多媒体控制 - 深紫色 */
}

.tool-category:nth-child(3) .tool-item:not(.mcp-tool) {
    border-left-color: #2ecc71; /* 云台控制 - 绿色 */
}

.tool-category:nth-child(4) .tool-item:not(.mcp-tool) {
    border-left-color: #e74c3c; /* 机械臂控制 - 红色 */
}

.tool-category:nth-child(5) .tool-item:not(.mcp-tool) {
    border-left-color: #f39c12; /* 文件操作 - 橙色 */
}

.tool-category:nth-child(6) .tool-item:not(.mcp-tool) {
    border-left-color: #9b59b6; /* 网络通信 - 深紫色 */
}

.tool-category:nth-child(7) .tool-item:not(.mcp-tool) {
    border-left-color: #16a085; /* 数学计算 - 青色 */
}

.tool-category:nth-child(8) .tool-item:not(.mcp-tool) {
    border-left-color: #e67e22; /* 物体检测 - 深橙色 */
}

.tool-category:nth-child(9) .tool-item:not(.mcp-tool) {
    border-left-color: #95a5a6; /* 其他工具 - 灰色 */
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.2);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268, #495057);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

/* 加载和通知样式 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background: #27ae60;
}

.notification.error {
    background: #e74c3c;
}

.notification.warning {
    background: #f39c12;
}

.notification-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.loading {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
}

/* LLM回复内容 */
.llm-response-content {
    margin-bottom: 12px;
    line-height: 1.5;
}

/* 工具调用显示样式 */
.tool-calling-container {
    background: linear-gradient(135deg, #fff3cd, #fffbf0);
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 13px;
}

.tool-calling-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #b8860b;
    margin-bottom: 8px;
    font-size: 12px;
}

.tool-calling-icon {
    font-size: 14px;
}

.tool-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tool-result-item {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 8px;
    position: relative;
}

.tool-result-item.error {
    border-color: #f5c6cb;
    background: #f8d7da;
}

.tool-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.tool-result-name {
    font-weight: 600;
    color: #495057;
    font-size: 12px;
}

.tool-result-status {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 500;
}

.tool-result-status.running {
    background: #fff3cd;
    color: #856404;
}

.tool-result-status.completed {
    background: #d4edda;
    color: #155724;
}

.tool-result-status.error {
    background: #f8d7da;
    color: #721c24;
}

.tool-result-content {
    color: #6c757d;
    font-size: 11px;
    line-height: 1.3;
    max-height: 150px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.tool-result-content.error {
    background: #f5c6cb;
    color: #721c24;
}

/* 图像上传样式 */
.image-upload-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.image-upload-button {
    width: 40px;
    height: 40px;
    border: none;
    background: #ecf0f1;
    color: #7f8c8d;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.image-upload-button:hover {
    background: #3498db;
    color: white;
    transform: scale(1.05);
}

.image-preview {
    max-width: 100px;
    max-height: 100px;
    margin-left: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.remove-image-button {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border: none;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.remove-image-button:hover {
    background: #c0392b;
}

/* 上传图像预览样式 */
.image-preview-container {
    max-width: 200px;
    max-height: 200px;
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.uploaded-image-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        order: -1;
    }
    
    .sidebar-section {
        margin-bottom: 15px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .welcome-message .message-content {
        max-width: 95%;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}
